1. Field of the Invention
The present invention relates to use of JMX beans in an application server environment.
2. Description of the Related Art
JAVA (a trademark of the Oracle Corporation) is an object-oriented language. JAVA programs are constructed using one or more objects which communicate to accomplish some task. Software objects are similar to real world objects in that they have both state and behaviors. The state of an object is stored in variables and their behaviors are implemented with methods. Variables are named records in which you can store data for later use. Methods are named pieces of code that implement behaviors the object is capable of.
JAVA programs may include many software objects of the same basic kind. In object-oriented terminology, each implementation or manifestation of the object is an “instance” of the generic class of the object. Each instance of the object has its own state, but every instance has the same methods defining their behavior. The object instances are constructed from a software blueprint, referred to as a “class definition,” which is written by a programmer. Accordingly, a class must declare instance variables to hold the object's state and include instructions for the methods that the object implements to form the behavior. In this manner, a class definition can be used to create objects of that class by instantiating them. When created, each object has memory allocated to it to hold its instance variables (i.e., its state). The state of each object is separate from that of the others. After an object is created, you can call its instance methods to have it do something.
In addition to instance variables and instance methods, the class can define static variables and static methods. Static variables are not duplicated in each instance. They store properties that belong to the class as a whole. Each instance of the class will get the same value when accessing a static variable. Collectively, instance variables and static variables are referred to as member variables because they are members of the class.
A JAVA object that represents a resource to be managed, such as an application, device or service, is referred to as a “managed bean” or simply an “MBean.” An MBean has a management interface consisting of the named and typed attributes that can be read and written, the named and typed operations that can be invoked, and the typed notifications that can be emitted by the MBean. For example, an MBean representing an application program's configuration could have attributes representing the different configuration parameters, such as a cache size. Reading the CACHESIZE attribute of the MBean would return the current size of the cache. Writing CACHESIZE would update the size of the cache, potentially changing the behavior of the running application. An operation such as “save” could store the current configuration persistently. The MBean could send out a notification such as CONFIGURATIONCHANGEDNOTIFICATION when the configuration changes.
MBeans can be standard or dynamic. Standard MBeans are JAVA objects that conform to design patterns derived from the JavaBeans component model. A standard MBean exposes the resource to be managed directly through its attributes and operations. Attributes are exposed through “getter” and “setter” methods. Operations are the other methods of the class that are available to managers. All these methods are defined statically in the MBean interface and are visible to a JMX agent through introspection. This is the most straightforward way of making a new resource manageable. A dynamic MBean is an MBean that defines its management interface at runtime. For example, a configuration MBean could determine the names and types of the attributes it exposes by parsing an XML file.
An MBean must be registered in a core managed object server, referred to as an “MBean server,” before the MBean can be used. An MBean server acts as a management agent, runs on most devices enabled for the JAVA programming language, and is a repository of MBeans. Each MBean is registered with a unique name within the MBean server. Other objects or application programs do not access an MBean directly, but rather access the MBean by name through the MBean Server.
There are generally two ways to create an MBean. One is to construct a Java object that will be the MBean, then use the REGISTERMBEAN method to register it in the MBean Server. The other is to create and register the MBean in a single operation using one of the CREATEMBEAN methods. An MBean can even perform actions when it is unregistered from an MBean Server if it implements the MBEANREGISTRATION interface.
JAVA Management Extensions (JMX) technology provides a JMX specification that defines an architecture, the design patterns, the APIs, and the services for application and network management and monitoring in the JAVA programming language. The JMX specification defines a JMX agent that manages resources instrumented in compliance with the specifications. A JMX agent includes an MBean server, MBeans that have been registered with the MBean server, and a set of services for handling MBeans. In this way, JMX agents directly control resources and make them available to remote management applications. JMX technology also defines standard connectors, known as “JMX connectors,” that provide access to JMX agents from remote management applications. JMX connectors using different protocols provide the same management interface. Hence a management application can manage resources transparently, regardless of the communication protocol used. JMX agents can also be used by systems or applications that are not compliant with the JMX specification but which support JMX agents.
FIG. 1 is a schematic diagram of an application server 10 having a JMX Agent 12 for managing resources 17, 19, 21. The JMX Agent 12 includes an MBean server 14, a plurality of MBeans 16, 18, 20 that are identified in a registry 22, and services 24 for handling the MBeans. The JMX Agent 12 also includes JMX connectors and protocol adapters 26 that enables access to the JMX Agent 12 via remote management application 28 and web browser 29.
While the use of MBeans provides numerous programming benefits, the programmer is still faced with the challenge of keeping the MBeans organized. This organizational challenge is greatest when modifying an existing MBean, since the original MBean must be unregistered and removed from the MBean Server and a modified MBean must be copied to the MBean Server and registered. It may also be necessary to save the original MBean in case the modified MBean does not work as intended and it becomes necessary to revert to the original MBean. It should also be recognized that numerous MBeans may be modified over time during the development of a program.
Therefore, there is a need for improved methods and systems for managing MBeans. It would be desirable if the methods and systems simplified the development and modification of MBeans. Most desirably, the methods and systems would simplify registration and unregistration of MBeans and provide improved organization for maintaining registered and unregistered MBeans.